

import { axios, get, post, patch, Delete } from './request';

// 解决跨域  (jsonp cors 反向代理 )
// 声明代理对象   这个对象可以代理前端的域名   映射后端的接口地址  



// 所有的接口封装这里  promise (async+await )
// 服务层 提供接口 提供数据
// 反向代理和基路径会有冲突 直接干掉基路径  默认前端的域名 
export const ajax = {
    test: (params) => get("/api/test", params),

    // 查询接口
    findUser: (params) => get("/api/hammer", params),

    // 添加接口
    addUser: (params) => post("/api/hammer", params),

    //商品
    list: (params) => get("/api/list", params),

    // 发送验证码  http://47.104.209.44:3333/
    // sendCaptcha:params=>get('http://47.104.209.44:3333/captcha/sent',params),

    // verifyCaptcha:params=>get('http://47.104.209.44:3333/captcha/verify',params),

    sendCaptcha: params => get('/wangyi/captcha/sent', params),

    verifyCaptcha: params => get('/wangyi/captcha/verify', params),

    // 卖座接口   跨域
    // getMaiData:(params,headers)=>get("https://m.maizuo.com/gateway",params,headers)
    // getMaiData: (params, headers) => get("/gateway", params, headers),

    // postMaiData: (params, headers) => post("/gateway", params, headers),



    //锤子数据
    getChui: (params, headers) => get("/mobile/new/home?channel_id=1002", params, headers),
    mobile: (params, headers) => get("/mobile/waterfall?page=2&pageSize=20&from=home", params, headers),

    // 分类数据

    classification: (params, headers) => get("/mobile/classify", params, headers),


    // 热门搜索
    hot: (params, headers) => get("/v1/search/hot-words", params, headers),
    // 搜索商品
    goods: (params, headers) => get("/product/search/sku", params, headers),

    //商品详情页
    item: (params, headers) => get("/product/spus", params, headers),


    // 点赞查询
    getLikeCount: (params) => get("/api/likes/", params),
    // 点赞添加
    addLikeOne: (params) => post("/api/likes", params),
    // 删除点赞
    removeLikeOne: (id, params) => Delete("/api/likes/" + id, params),

    // 收藏查询
    addcollection: (params) => get("/api/collection/", params),

    // 收藏添加
    cddcollection: (params) => post("/api/collection/", params),
    // 收藏删除
    bddcollection: (id, params) => Delete("/api/collection/" + id, params),

    // 地址
    dizi: (params) => get("/api/address/", params),


    //商品添加购物车

    cart: (params) => post("/api/cart", params),

    caxun: (params) => get("/api/cart", params),

    // 修改购物车数量

    changeCartOne: (id, params) => patch("/api/cart/" + id, params),


    // 购物车删除
    removeCartOne: (id) => Delete("/api/cart/" + id),



    // 新增地址
    address: (params) => post("/api/add", params),

    // 查下地址

    ress: (params) => get("/api/add/", params),

}
